package com.demo;

import java.util.List;

import org.springframework.stereotype.Service;

import io.ebean.Ebean;
import io.ebean.EbeanServer;

@Service
public class UserService {

	private EbeanServer ebeanServer = Ebean.getDefaultServer();

	/**
	 * 查询全部
	 * @return
	 */
	public List<User> getAll() {
		return ebeanServer.find(User.class).setFirstRow(0).setMaxRows(10).findList();
	}


	/**
	 * 查询指定的字段
	 * @return
	 */
	public List test() {
		List<User> user = ebeanServer.find(User.class).setDisableLazyLoading(true).select("id,username").findList();
		return user;
	}
}
